create procedure tls.sp_IncId @TableName varchar(100), @NextId int out as
begin
	declare @TranStarted bit
	if @@trancount = 0 
		set @TranStarted = 1
	else
		set @TranStarted = 0
	if @TranStarted = 1 
	begin 
		begin tran
		set xact_abort on
	end
	if 1 = 2 set @TableName = null --resolving fmtonly problem
	select @NextId = NextId + 1 from tls.IdTable with (rowlock, holdlock, xlock)   
	where TableName = @TableName
	
	update tls.IdTable  
	set NextId = @NextId   
	where TableName = @TableName
	
	if @TranStarted = 1 and @@trancount > 0
		commit tran
end